package com.msb;

import org.apache.zookeeper.*;

/**
 * @author sunpeng
 * @Date 2021-07-21 9:14
 */

public class SendContent {

    public static void main(String[] args) throws Exception {

        //zookeeper对象：ip地址+端口号、超时时间、当连接成功后编写连接信息
        ZooKeeper zooKeeper = new ZooKeeper("10.1.20.89:2181", 10000, new Watcher() {
            public void process(WatchedEvent watchedEvent) {
                System.out.println("获取连接");
            }
        });
        //发送内容：路径、内容、权限、内容的模式（临时永久、是否允许重复）
        String content = zooKeeper.create("/demo/address", "xian".getBytes(), ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT_SEQUENTIAL);
        System.out.println(content);
    }

}
